﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class UserAuthorizationControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        CustomGridView CustomGridList1;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            CustomGridList1 = (CustomGridView)FindControl("CustomGridList1");
            if (!base.Page.IsPostBack)
            {
                Bind();
            }
            CustomGridList1.OnLoadData += new EventHandler(CustomGridList1_OnLoadData);
        }
        private void Bind()
        {
            DataTable dt = null;
            if (_EluZSDataProvider.IsNetZSAdmin(userid) || _EluZSDataProvider.IsZSAdmin(userid))
            {
                dt = _EluZSDataProvider.GetYHSQ("");
            }
            else
            {
                dt = _EluZSDataProvider.GetYHSQ(userid);
            }
            CustomGridList1.DataSource = dt;
            CustomGridList1.RecordCount = dt.Rows.Count;
            CustomGridList1.DataKeyNames = new string[] { "ID" };
            CustomGridList1.DataBind();
        }

        protected void CustomGridList1_OnLoadData(object sender, EventArgs e)
        {
            Bind();
        }
    }
}


